//
//  MovieCollectionViewCell.m
//  DouBan
//
//  Created by dllo on 16/6/24.
//  Copyright © 2016年 zuzhiming. All rights reserved.
//

#import "MovieCollectionViewCell.h"
#import "MovieModel.h"
#import "Masonry.h"
#import "UIImageView+WebCache.h"
@interface MovieCollectionViewCell ()
@property (nonatomic, retain) UIImageView *mvImageView;
/**  底部标题 */
@property (nonatomic, retain) UILabel *bottomLabel;

@end

@implementation MovieCollectionViewCell

- (void)dealloc
{
    [_mvImageView release];
    [_bottomLabel release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.mvImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:_mvImageView];
        [_mvImageView release];
        
        self.bottomLabel = [[UILabel alloc] init];
        [self.contentView addSubview:_bottomLabel];
        [_bottomLabel release];
    }
    return self;
}

- (void)setMvMod:(MovieModel *)mvMod
{
    if (_mvMod != mvMod) {
        [_mvMod release];
        _mvMod = [mvMod retain];
    }
    [self.mvImageView sd_setImageWithURL:[NSURL URLWithString:_mvMod.pic_url] placeholderImage:[UIImage imageNamed:@"bg_eventlistcell"]];
    self.bottomLabel.text = _mvMod.movieName;
    
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    self.bottomLabel.textAlignment = NSTextAlignmentCenter;
    
    [self.mvImageView makeConstraints:^(MASConstraintMaker *make) {
        make.edges.offset(UIEdgeInsetsMake(0, 0, 30, 0));
    }];
    [self.bottomLabel makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.mvImageView.bottom).offset(0);
        make.bottom.equalTo(self.contentView.bottom).offset(0);
        make.left.equalTo(self.contentView.left).offset(0);
        make.right.equalTo(self.contentView.right).offset(0);
    
    }];
}

@end
